package com.example.blog.module.utils;

import com.example.blog.module.entity.SysUser;

/**
 *  可以在同一线程中很方便的获取用户信息，不需要频繁的传递session对象。
 */
public class BaseContent {

    private BaseContent(){}
    //线程变量隔离
    private static final ThreadLocal<SysUser> LOCAL = new ThreadLocal<>();

    public static void put(SysUser sysUser){
        LOCAL.set(sysUser);
    }
    public static SysUser get(){
        return LOCAL.get();
    }
    public static void remove(){
        LOCAL.remove();
    }

}
